package com.glasses.spectrum;

import java.io.Serializable;
import java.util.Locale;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author Jean-Luc Burot
 * @since 2014-12-13
 * @version 1
 */

@Named
@RequestScoped
public class GetParam implements Serializable {
    @Inject
    @ManagedPropertyInject("#{param.view}")
    private String view;
    
    @Inject
    @ManagedPropertyInject("#{param.language}")
    private String language;
    
    public String getView() {
        return view;
    }
    
    public void setView(String view) {
        this.view = view;
    }
    
    public String getLanguage() {
        //Set default language if no language is yet set.
        if ("".equals(this.language)) {
            Locale browserLocale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
            this.setLanguage(browserLocale.getLanguage());
        }
        
        return language;
    }
    
    public void setLanguage(String language) {
        this.language = language;
    }
}
